Skip to content

feat(desktop): gate sources panel add-source button on launch flag - #11632

Closed
callmeYe wants to merge 1 commit into
mainfrom
desktop/hide-add-source-button
Closed

callmeYe wants to merge 1 commit into
mainfrom
desktop/hide-add-source-button

Conversation

@callmeYe

@callmeYe callmeYe commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

Hides the "+" button in the header of the sources panel by default. The button's code path is kept intact: launching the desktop app with the environment variable CRAFT_FEATURE_ADD_SOURCE_BUTTON=1 brings it back. The flag is evaluated in the preload process (the renderer cannot read environment variables) and exposed to the renderer through the existing preload-local API pattern, so checking it costs no IPC round-trip. The web build always reports the button as hidden, and the component playground keeps it visible so the add-source popover remains developable there. Other entry points for adding a source — the panel's empty state and the sidebar context menu — are unchanged.

Why it's needed

The plus button in the sources panel header serves no practical purpose in the current product flow, but deleting the code outright would throw away a working add-source interaction that may still be wanted for debugging or future iterations. Hiding it behind a launch flag declutters the default UI while keeping the behavior one environment variable away.

Reviewer Test Plan

How to verify

  1. From packages/desktop, run bun run electron:dev, open a workspace, and switch to the sources panel: the header shows no "+" button, and the rest of the panel (source list, item menus, empty state) behaves as before.
  2. Relaunch with CRAFT_FEATURE_ADD_SOURCE_BUTTON=1 bun run electron:dev: the "+" button reappears in the sources panel header and still opens the add-source popover.
  3. Run cd packages/desktop/apps/electron && bun test src/transport/__tests__/channel-map-parity.test.ts — it passes, with the new preload-local API registered in the exclusion list.

Evidence (Before & After)

Runtime smoke on macOS: the dev app boots cleanly both with the flag unset and with CRAFT_FEATURE_ADD_SOURCE_BUTTON=1 (window created, renderer connected over RPC, no preload or renderer errors in the app log), and the built preload bundle contains the flag evaluation. Visual before/after screenshots of the header were not captured — the dev launcher opens no remote-debugging port, so the window could not be inspected programmatically; the behavior change itself is a single conditional render on the flag.

Tested on

OS Status
🍏 macOS ✅ tested
🪟 Windows ⚠️ not tested
🐧 Linux ⚠️ not tested

Environment (optional)

bun run electron:dev from packages/desktop (Vite dev server + Electron).

Risk & Scope

  • Main risk or tradeoff: the renderer now calls a preload-local synchronous API while rendering the panel header; the method exists in all three API implementations (Electron preload, web adapter, playground mock), and the channel-map parity test guards the contract at compile time.
  • Not validated / out of scope: Windows and Linux runtime behavior; the web UI keeps the button hidden unconditionally.
  • Breaking changes / migration notes: none — the only default behavior change is the hidden button, and setting the environment variable restores it.

Linked Issues

N/A

中文说明

本 PR 做了什么

默认隐藏来源面板头部的 "+" 按钮。按钮的代码路径完整保留:启动桌面应用时设置环境变量 CRAFT_FEATURE_ADD_SOURCE_BUTTON=1 即可恢复显示。该开关在 preload 进程中求值(渲染进程无法读取环境变量),并通过现有的 preload 本地 API 模式暴露给渲染进程,因此读取开关不需要 IPC 往返。Web 版本始终报告按钮为隐藏状态;组件 playground 中保持可见,以便继续在其中开发"添加来源"弹层。添加来源的其他入口——面板的空状态按钮和侧边栏右键菜单——均不受影响。

为什么需要

来源面板头部的加号按钮在当前产品流程中没有实际意义,但直接删除代码会丢掉一个可用的添加来源交互,将来调试或迭代时可能仍需要。用启动开关把它隐藏起来,既让默认界面更干净,又让该行为只需一个环境变量即可找回。

评审者验证计划

如何验证

  1. packages/desktop 下运行 bun run electron:dev,打开一个工作区并切换到来源面板:头部不再显示 "+" 按钮,面板其余部分(来源列表、条目菜单、空状态)行为与之前一致。
  2. CRAFT_FEATURE_ADD_SOURCE_BUTTON=1 bun run electron:dev 重新启动:"+" 按钮重新出现在来源面板头部,且仍能打开添加来源弹层。
  3. 运行 cd packages/desktop/apps/electron && bun test src/transport/__tests__/channel-map-parity.test.ts——测试通过,新的 preload 本地 API 已登记在排除列表中。

证据(前后对比)

macOS 上的运行时冒烟验证:不设置开关和设置 CRAFT_FEATURE_ADD_SOURCE_BUTTON=1 两种情况下开发应用均正常启动(窗口已创建,渲染进程通过 RPC 连接,应用日志中无 preload 或渲染进程错误),且构建出的 preload 包中包含开关求值逻辑。未截取头部的前后对比截图——开发启动器没有开放远程调试端口,无法以编程方式检查窗口;行为变化本身只是基于该开关的一处条件渲染。

已测试平台

macOS ✅ 已测试;Windows ⚠️ 未测试;Linux ⚠️ 未测试。

环境(可选)

packages/desktop 下运行 bun run electron:dev(Vite 开发服务器 + Electron)。

风险与范围

  • 主要风险或权衡:渲染进程在渲染面板头部时会调用一个 preload 本地的同步 API;该方法在三处 API 实现(Electron preload、Web 适配器、playground mock)中均已提供,channel-map 一致性测试在编译期守护该契约。
  • 未验证 / 不在范围内:Windows 和 Linux 的运行时行为;Web 界面无条件保持按钮隐藏。
  • 破坏性变更 / 迁移说明:无——默认行为变化仅为隐藏按钮,设置环境变量即可恢复。

关联 Issue

The "+" button in the sources panel header serves no practical purpose
in the current product flow, so it is now hidden by default. The code
path is kept intact and can be re-enabled at launch with
CRAFT_FEATURE_ADD_SOURCE_BUTTON=1. The flag is evaluated in the
preload (which can read env vars) and exposed to the renderer as a
preload-local API, following the getRuntimeEnvironment precedent.
@qwen-code-ci-bot

qwen-code-ci-bot commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Qwen Triage finishedview run. See the stage comments in this thread for the result.

Qwen Triage 已完成 —— 查看运行。结果见本线程中的各阶段评论。

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@callmeYe thanks for the write-up — the description is thorough and the flag design itself is sensible. I have to stop this at the gate, though, for a reason that has nothing to do with the approach: the code this PR changes no longer exists in this repository.

  • All 7 files are under packages/desktop/**. That tree was deleted from main on 2026-08-25 by #9085"feat(desktop): remove the Electron package after OpenWork fork; keep the Tauri upgrade bridge" — 1723 files, −383,635 lines.
  • The branch is based on 6ebc79f6, which is 1090 commits behind main, and GitHub reports the PR as conflicting / not mergeable. Rebasing onto main would not hand you conflicts to resolve — it would hand you an empty diff.
  • Nothing on main carries this surface today. Searching the current tree for isAddSourceButtonEnabled, isSourcesNavigation, EditPopover, HeaderIconButton, add-source, @craft-agent and CRAFT_FEATURE_ returns zero hits, and there is no root bun.lock — so the bun run electron:dev and bun test ... steps in your test plan cannot run against this repo at all.
  • Consistent with that, there is no CI signal to review: the head SHA c32fd41f has six workflow runs and all six are pull_request_target bot jobs. Qwen Code CI never fired, and verify / precheck-pr / review-config are all skipped. Most likely because GitHub cannot build a merge ref for a conflicting PR; I won't guess harder than that.

So this is not a "fix the rebase and come back" situation. The sources panel header, the add-source popover, the preload-local API pattern and the feature-flags.ts you extended all belong to the Electron app that was forked out to OpenWork. If hiding that button is still wanted, it belongs in whichever repository now carries that app — the change is small and self-consistent, and I'd expect it to land easily there.

If you actually meant to change something that is on main, the only desktop surface left here is packages/desktop-shell, which is the Tauri upgrade bridge (bootstrap, runtime, src-tauri) and has no renderer UI and no sources panel. Tell us what behavior you were after and we can work out where it belongs now.

And if this branch was simply pushed to the wrong remote, closing the PR is the right move — no harm done.

中文说明

@callmeYe 感谢详细的 PR 说明——描述很完整,开关本身的设计也合理。但这个 PR 需要在准入阶段拦下,原因与方案无关:它修改的代码在本仓库中已经不存在了。

  • 7 个文件全部位于 packages/desktop/**。该目录已于 2026-08-25 由 #9085main 删除——"feat(desktop): remove the Electron package after OpenWork fork; keep the Tauri upgrade bridge",共 1723 个文件、−383,635 行。
  • 分支基于 6ebc79f6,落后 main 1090 个提交,GitHub 判定为冲突/不可合并。rebase 到 main 不会给你需要解决的冲突,只会给你一个空 diff。
  • 当前 main 上已无这些代码痕迹:在现有代码树中检索 isAddSourceButtonEnabledisSourcesNavigationEditPopoverHeaderIconButtonadd-source@craft-agentCRAFT_FEATURE_ 均无命中;仓库根目录也没有 bun.lock,因此验证步骤里的 bun run electron:devbun test ... 在本仓库根本无法执行。
  • 与此一致,没有可供审查的 CI 信号:head SHA c32fd41f 上共 6 次 workflow 运行,全部是 pull_request_target 的机器人任务。Qwen Code CI 从未触发,verify / precheck-pr / review-config 均为 skipped。很可能是因为 PR 冲突导致 GitHub 无法构造 merge ref——这一点我不再做进一步推测。

所以这不是"rebase 一下再来"的问题。来源面板头部、添加来源弹层、你扩展的 preload 本地 API 模式以及 feature-flags.ts,都属于已经 fork 到 OpenWork 的那个 Electron 应用。如果仍然需要隐藏该按钮,应该提到现在承载该应用的仓库去——改动本身小而自洽,在那边大概很容易合入。

如果你原本想改的是当前 main 上的东西,这里仅剩的桌面相关模块是 packages/desktop-shell,即 Tauri 升级桥接(bootstrapruntimesrc-tauri),它没有渲染层 UI,也没有来源面板。请说明你想改变的行为,我们再一起确认它现在应该落在哪里。

如果这个分支只是推错了远端,直接关闭 PR 即可,没有任何问题。

Qwen Code · qwen3.8-max-2026-09-02

@callmeYe

Copy link
Copy Markdown
Collaborator Author

Closing: this targeted packages/desktop, which was removed from main in #9085 (desktop code moved to the OpenWork fork). The intended change is for the Web Shell sources panel instead — a new PR against packages/web-shell will supersede this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants